package com.genericdao.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.genericdao.intf.UserService;
import com.genericdao.pojo.User;
import com.opensymphony.xwork2.ActionSupport;

//@ParentPackage("struts-default")
//@Namespace("/")//使用convention-plugin插件提供的@Namespace注解为这个Action指定一个命名
//@Results({@Result(name="success",location="/content/success.jsp"),@Result(name="error",location="/content/error.jsp")})
public class TestAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	//@Autowired
	private UserService userService;

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Override
	public String execute() throws Exception {
		
		User user = new User();
		user.setName("TestMaven");
		user.setPassword("******");
		
		System.out.println("----------------------------->user service:"+userService);
		
		userService.add(user);
		
		return SUCCESS;
	}

}
